// 父类
function Person(name, age, friends) {
  this.name = name
  this.age = age
  this.friends = friends
}
Person.prototype.eating = function() {
  console.log(this.name + " eating");
}
// 子类
function Student(name, age, friends, sno) {
  // 借用构造函数
  Person.call(this, name, age, friends);
  this.sno = sno;
}
// 直接将父类赋值给子类，这种方案是不正确的
Student.prototype = new Person();
Student.prototype.studying = function() {
  console.log(this.name + " studying");
}
// 解决第3个弊端
var stu1 = new Student("yz", 18, ["kobe"], 111)
var stu2 = new Student("yz2", 20, ["james"], 130)

// 解决第1个弊端
console.log(stu1);
stu1.eating()

stu1.friends.push("haha");

// 解决第2个弊端
console.log(stu1.friends);
console.log(stu2.friends);

// 弊端
// 1.Person函数至少被调用两次
// 2.stu原型对象上会多余属性


